package com.itheima.dao;

import com.itheima.pojo.Permission;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface PermissionMapper {

    List<Permission> findPage(@Param("queryString") String queryString);

    @Insert("insert into t_permission (name,keyword,description) values (#{name},#{keyword},#{description})")
    void add(Permission permission);

    @Select("select * from t_permission where id=#{id}")
    Permission findById(@Param("id")Integer id);

    void updata(Permission permission);

    @Delete("delete from t_permission where id = #{id}")
    void delete(@Param("id")Integer id);

    @Select("select count(*) from t_role_permission where permission_id = #{id}")
    Integer findRolAndPermissionById(@Param("id")Integer id);

    @Select("select * from t_permission")
    List<Permission> findAll();

    @Select("select permission_id from t_role_permission where role_id = #{id}")
    List<Integer> findByRoleId(@Param("id")Integer id);

    @Select("delete from t_role_permission where role_id = #{id}")
    void deleteByRoleId(@Param("id")Integer id);
}
